import axios from 'axios';



import {
  Loading, Message,   MessageBox
} from 'element-ui'


axios.defaults.baseURL = "http://127.0.0.1:8080/his";
axios.defaults.withCredentials = true


export default {
		
	get:function( url,  callback ,params={} ,msg ){
		const loading = Loading.service({
			lock: true,
			text: 'Loading',
			spinner: 'el-icon-loading',
			background: 'rgba(0, 0, 0, 0.7)'
		});
		
		setTimeout(() => {
			loading.close();
		}, 8000);
		
		// 
		axios.get( url, {
				params: params
			})
			.then((data) => {
				// console.log(data); //可以看下控制台，此处的输出
		
				if (data.status == 200) { // axios  200 
					let commonresult = data.data; //commonresult 
					loading.close();
					if (commonresult.code == 200) {
						// console.log(commonresult.data)
						callback(commonresult.data)
						if(msg && msg.length>0){
							Message.success(msg);
						}
					}else{
						Message.error(commonresult.msg);
					}
					
				}else{
					Message.error('业务操作异常，请联系管理员');
				}
		
			}).catch(() => {
				Message.error('系统异常');
			})
	}
	
	
}



